<!--
 * @Author: ckk
 * @Date: 2023-08-21 16:19:56
 * @LastEditTime: 2023-08-23 15:50:02
 * @Description: 消息列表
 * @version: 1.0
-->
<template>
  <div class="message-component" v-if="datas.setStyle">
    <div class="message-item" v-for="(item,index) in datas.setStyle.imageList" :key="index" @click="JumpUrl(item.url)">
      <img :src="item.src" alt="">
      <div class="item-content">
        <p class="message-title">{{item.text}}</p>
        <p class="message-desc">{{item.desc}}</p>
      </div>
    </div>
  </div>
</template>
<script>
import YouXin from 'youxin-js-sdk';
import { getLink } from '../../common/comfun';
export default {
  name: 'messageComponent',
  components: {
  },
  props: {
    datas: Object
  },
  watch: {
  },
  data () {
    return {
    };
  },
  created () {
    console.log(this.datas, 'pdatas');
  },
  methods: {
    /**
     * @author: ckk
     * @description:
     * @param {*} url
     * @return {*}
     */
    JumpUrl (url) {
      if (url.indexOf('https://') !== -1 || url.indexOf('http://') !== -1) {
        YouXin.openWindow({
          url: url, // 网页地址
          title: '' // 标题名称
        });
      } else if (url.indexOf('vcom-area://h5') !== -1) {
        this.$router.push({ path: getLink(url), query: { isGo: '1' } });
      } else if (url.indexOf('vcom-area://') !== -1) {
        const newUrl = url.split('://')[1];
        YouXin.openWindow({
          url: location.origin + newUrl, // 网页地址
          title: '' // 标题名称
        });
      } else if (url.indexOf('vcom://') !== -1) {
        this.$toast('暂无跳转链接');
      } else {
        YouXin.openWindow({
          url: location.origin + url, // 网页地址
          title: '' // 标题名称
        });
      }
    }
  }
};
</script>

<style scoped lang="scss">
.message-item{
  display: flex;
  align-items: center;
  padding:16px 15px;
  background: #fff;
  img{
    width:48px;
    height: 48px;
    display: block;
    border-radius: 50%;
    overflow: hidden;
    margin-right:10px;
  }
  .message-title{
    font-size: 16px;
    font-family: PingFang SC-Regular, PingFang SC, sans-serif;
    font-weight: 400;
    color: #333333;
    line-height: 19px;
    padding-bottom:8px
  }
  .message-desc{
    font-size: 12px;
    font-family: PingFang SC-Regular, PingFang SC, sans-serif;
    font-weight: 400;
    color: #999999;
    line-height: 14px;
  }
}
</style>
